package com.guan.study.easyExcelDemo.write.write01_简单写;

import com.alibaba.excel.EasyExcel;
import com.guan.study.easyExcelDemo.Student;
import java.util.ArrayList;
import java.util.List;

/**
 * @Date: 2023/7/2 10:20
 * @Author: yaobai
 * @Description: 简单的写，没有合单元格的导出
 */
public class WriteExcel01 {

    private static final String PATH = "E:\\WorkDirTest2\\";

    public static void main(String[] args) {

        String fileName2 = PATH + System.currentTimeMillis() + "学生统计表.xlsx";
        EasyExcel.write(fileName2, Student.class)
                .sheet()
                .doWrite(data2());

        System.out.println("写入完毕");

    }

    /**
     * @date: 2023/7/20 15:27
     * @author: yaobai
     * @description: 模拟数据库查询到的数据
     * @param:
     * @return:
     **/
    private static List<Student> data2(){

        List<Student> list = new ArrayList<>();

        for (int i = 0; i < 20; i++) {
            Student student = Student
                    .builder()
                    .name("刘总"+i)
                    .age(22+i)
                    .addr("北京")
                    .school("北京大学")
                    .chinese("98")
                    .math("69")
                    .english("99")
                    .build();
            list.add(student);
        }

        return list;
    }

}
